import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useDataStore = defineStore('data', () => {
    // 模拟数据
    const teachingProjects = ref([
        {
            id: 1,
            name: '管理信息系统课程改革',
            type: '教改项目',
            level: '校级',
            status: '执行中',
            startDate: '2023-09-01',
            endDate: '2024-08-31',
            leader: '张教授',
            funding: 10000
        },
        {
            id: 2,
            name: '数据库原理教材建设',
            type: '教材建设项目',
            level: '省部级',
            status: '已立项',
            startDate: '2023-10-01',
            endDate: '2025-09-30',
            leader: '张教授',
            funding: 50000
        }
    ])

    const researchProjects = ref([
        {
            id: 1,
            name: '大数据环境下的智能决策支持系统研究',
            type: '纵向项目',
            level: '国家级',
            status: '执行中',
            startDate: '2023-01-01',
            endDate: '2025-12-31',
            leader: '张教授',
            funding: 300000
        },
        {
            id: 2,
            name: '企业信息化管理系统开发',
            type: '横向项目',
            level: '市厅级',
            status: '已结题',
            startDate: '2022-06-01',
            endDate: '2023-12-31',
            leader: '张教授',
            funding: 150000
        }
    ])

    const awards = ref([
        {
            id: 1,
            name: '教学成果奖',
            project: '管理信息系统课程改革',
            category: '教学成果奖',
            level: '省部级',
            grade: '二等奖',
            date: '2023-09-15',
            organization: '教育部'
        },
        {
            id: 2,
            name: '优秀教师',
            project: '',
            category: '个人荣誉',
            level: '校级',
            grade: '优秀',
            date: '2023-07-01',
            organization: '某某大学'
        }
    ])

    const lectures = ref([
        {
            id: 1,
            title: '人工智能在企业管理中的应用',
            type: '学术讲座',
            organization: '北京大学',
            location: '北京大学光华管理学院',
            date: '2023-10-15',
            duration: 120,
            role: '主讲人'
        }
    ])

    const activities = ref([
        {
            id: 1,
            name: '中国管理科学与工程学会年会',
            type: '学术会议',
            organization: '中国管理科学与工程学会',
            location: '上海',
            startDate: '2023-11-01',
            endDate: '2023-11-03',
            role: '参会代表',
            hasReport: true,
            reportTitle: '智能决策支持系统的理论与实践'
        }
    ])

    // 添加项目
    const addTeachingProject = (project) => {
        teachingProjects.value.push({
            ...project,
            id: Date.now()
        })
    }

    const addResearchProject = (project) => {
        researchProjects.value.push({
            ...project,
            id: Date.now()
        })
    }

    const addAward = (award) => {
        awards.value.push({
            ...award,
            id: Date.now()
        })
    }

    const addLecture = (lecture) => {
        lectures.value.push({
            ...lecture,
            id: Date.now()
        })
    }

    const addActivity = (activity) => {
        activities.value.push({
            ...activity,
            id: Date.now()
        })
    }

    return {
        teachingProjects,
        researchProjects,
        awards,
        lectures,
        activities,
        addTeachingProject,
        addResearchProject,
        addAward,
        addLecture,
        addActivity
    }
})